package com.example.demo.delayQueue;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadQueueTest {
    public static void main(String[] args) {
        ArrayBlockingQueue linked = new ArrayBlockingQueue(2);
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2,3,1L, TimeUnit.SECONDS,linked);
        ThreadQueueRunnable runnable  = new ThreadQueueRunnable();
        System.out.println("before thread pool execute linked size is :"+linked.size());
        threadPoolExecutor.execute(runnable);
        threadPoolExecutor.execute(runnable);
        threadPoolExecutor.execute(runnable);
        threadPoolExecutor.execute(runnable);
        threadPoolExecutor.execute(runnable);
        System.out.println("after thread pool execute linked size is :"+linked.size());
        System.out.println("thread pool size is:" + threadPoolExecutor.getPoolSize());
    }
}


class ThreadQueueRunnable implements Runnable{
    @Override
    public void run() {
        System.out.println("--------------------");
        System.out.println(Thread.currentThread().getName());
        System.out.println("---------------------");
    }
}
